home *** CD-ROM | disk | FTP | other *** search
- Path: holly.ACNS.ColoState.EDU!not-for-mail
- From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
- Newsgroups: comp.lang.c++
- Subject: Proper use of friend keyword
- Date: 31 Mar 1996 16:17:40 -0700
- Organization: Colorado State University, Fort Collins, CO 80523
- Message-ID: <4jn3qk$3tl6@holly.ACNS.ColoState.EDU>
- NNTP-Posting-Host: holly.acns.colostate.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hey all, I have a question about how to use the friend keyword. Consider
- the following example:
-
- class.h---------
- class ABC
- {
- int AValue;
- int GetAValue() { return (AValue); }
- public:
- ABC() { AValue=5; }
- ~ABC(){ }
- };
-
- class XYZ
- {
- public:
- XYZ() { }
- ~XYZ() { }
- friend int ABC::GetAValue();
- };
-
- prog.C--------------------
- #include <iostream.h>
- #include "class.h"
-
- void main()
- {
- ABC abc;
- XYZ xyz;
-
- cout << xyz.GetAValue() << endl
- }
-
-
- when I try to compile this, I get the message "no member funciton
- 'XYZ::GetAValue()' defined." What do I need to do in order to
- make this work. Thanks for any and all suggestions.
-
- // ------------ BEGIN SIGNATURE ---------------
- #include <iostream.h>
- void main(void)
- {
- cout << "\aName:\tCorby S. Hudnall\n"
- << "School:\tColorado State University\n"
- << "\tDepartement of Computer Science\n"
- << "EMail:\thudnall@CS.ColoState.EDU\n"
- << "URL:\thttp://WWW.CS.ColoState.EDU/~hudnall\n";
- }
- // ------------ END SIGNATURE -----------------
-
-
-